package mx.itesm.twritter.server.map;

import org.python.util.PythonInterpreter;

public class PyCalls {
	public static final PythonInterpreter py = new PythonInterpreter();
	public boolean success;
	public String route;
	
	public PyCalls(){	
	}
	
	public PyCalls(String libPath, String mapPath){
		py.exec("import sys");
		py.exec("sys.path.append('"+libPath+"')");
		py.exec("import route");
		py.exec("router = route.Router(route.LoadOsm('"+mapPath+"'))");
	}
	
	public void CalculateRoute(int node1, int node2, String transport){
		py.exec("result, rout = router.doRouteAsLL("+node1+", "+node2+", '"+transport+"')");
		this.success = (py.get("result").toString().equals("success"));
		this.route = py.get("rout").toString();
		System.out.println(success + " " + route);
	}
	
	public String GetRoute(){
		return this.route;
	}
	
}